package com.mvp.method2.imvp.login;

import com.hhx.baselibrary.bean.BaseResponse;
import com.hhx.test_library.bean.Login;
import com.mvp.method2.retrofit.APIServiceManager;
import com.mvp.method2.retrofit.HttpObserver;

import java.util.HashMap;

/**
 * Created by Administrator on 2019/3/6.
 */

public class LoginPresenter extends LoginContract.Presenter {

    @Override
    public void login(HashMap<String, Object> map) {
        getView().showLoading();
        addSubscription(APIServiceManager.getInstance().getApiService().login(map), new HttpObserver<BaseResponse<Login>>() {

            @Override
            public void onSuccess(BaseResponse<Login> loginBaseResponse) {
                getView().refreshSuccess(loginBaseResponse);
            }

            @Override
            public void onFailure(String msg) {
                getView().refreshFailed(msg);
            }

            @Override
            public void onFinish() {
                getView().dismissLoading();
            }
        });
    }

 /*   public LoginPresenter(LoginContract.View view) {
        attachView(view);
    }

    public void login(HashMap<String, Object> map) {
        mView.showLoading();
        addSubscription(APIServiceManager.getInstance().getApiService().login(map), new HttpObserver<BaseResponse<Login>>() {

            @Override
            public void onSuccess(BaseResponse<Login> loginBaseResponse) {
                mView.refreshSuccess(loginBaseResponse);
            }

            @Override
            public void onFailure(String msg) {
                mView.refreshFailed(msg);
            }

            @Override
            public void onFinish() {
                mView.dismissLoading();
            }
        });
    }*/
}
